package com.kiln.juxingqs.adapter

import androidx.recyclerview.widget.DiffUtil
import client.global.commlib.base.BasePagingAdapter
import client.global.commlib.base.PagingViewHoder
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.Jyjl
import com.kiln.juxingqs.databinding.LayoutJydetailitemBinding

class PagingJydetailAdapter :
    BasePagingAdapter<Jyjl.Bath>(object : DiffUtil.ItemCallback<Jyjl.Bath>() {
        override fun areItemsTheSame(
            oldItem: Jyjl.Bath,
            newItem: Jyjl.Bath
        ): Boolean {
            return false
        }

        override fun areContentsTheSame(
            oldItem: Jyjl.Bath,
            newItem: Jyjl.Bath
        ): Boolean {
            return oldItem == newItem
        }
    }) {

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutJydetailitemBinding
        val bean = t as Jyjl.Bath
        binding.bean = bean
        val time = bean.create_time.substring(5, bean.create_time.length - 3)
        binding.time = time

        var color: Int = when (bean.bash_status) {
            1 -> R.color.lightGreen
            else -> R.color.priceRed
        }
        binding.tvType.setTextColor(holder.itemView.context.resources.getColor(color))
    }

    override fun getItemLayout(): Int {
        return R.layout.layout_jydetailitem
    }
}